package de.jabc.sib.bio.ebi;

import de.jabc.adapter.bio.ebi.Branches;
import de.jabc.adapter.bio.ebi.LightweightServiceAdapter;
import de.jabc.adapter.bio.ebi.ServiceAdapter;
import de.metaframe.jabc.framework.execution.ExecutionEnvironment;
import de.metaframe.jabc.framework.sib.annotation.SIBClass;
import de.metaframe.jabc.framework.sib.annotation.SIBStatus;
import de.metaframe.jabc.framework.sib.parameter.ContextExpression;
import de.metaframe.jabc.framework.sib.parameter.ContextKey;
import de.metaframe.jabc.sib.ServiceAdapterDescriptor;

/**
 * Calls the ArrayExpress web service to search for experiments.
 * 
 * @author anna-lena
 * @version $Revision: 3325 $ $Date: 2008-03-03 13:34:38 +0100 (Mon, 03 Mar 2008) $
 */
@SIBClass("ebi-sibs/ArrayExpressExperiments")
@SIBStatus("IMPLEMENTED")
public class ArrayExpressExperiments extends AbstractSIB {

	/* Branches */
	public static final String[] BRANCHES = { Branches.DEFAULT, Branches.ERROR };
	
	/* Parameters */
	public ContextExpression Keywords = new ContextExpression("prostate", String.class, false);
	public ContextExpression Accession = new ContextExpression("", String.class, false);
	public ContextExpression Array = new ContextExpression("", String.class, false);
	public ContextExpression Ef = new ContextExpression("", String.class, false);
	public ContextExpression Efv = new ContextExpression("", String.class, false);
	public ContextExpression Expdesign = new ContextExpression("", String.class, false);
	public ContextExpression Exptype = new ContextExpression("", String.class, false);
	public ContextExpression Gxa = new ContextExpression("", String.class, false);
	public ContextExpression Pmid = new ContextExpression("", String.class, false);
	public ContextExpression Sa = new ContextExpression("", String.class, false);
	public ContextExpression Species = new ContextExpression("", String.class, false);
	boolean Expandefo = false;
	public ContextKey result = new ContextKey("result", ContextKey.Scope.LOCAL, true);
	
	
	/**
	 * @see de.metaframe.jabc.sib.CodeGeneratorBlock#execute(ExecutionEnvironment)
	 */
	public String execute(ExecutionEnvironment environment) {
		try {
			return ServiceAdapter.callArrayExpressExperiments(environment, this.Keywords, 
					this.Accession, this.Array, this.Ef, this.Efv, this.Expdesign, this.Exptype,
					this.Gxa, this.Pmid, this.Sa, this.Species, this.Expandefo, this.result);
		} catch (NoClassDefFoundError e) {
			return Branches.ERROR;
		}
	}

	/**
	 * @see de.metaframe.jabc.sib.Generatable#generate()
	 */
	public ServiceAdapterDescriptor generate() {
		return new ServiceAdapterDescriptor(LightweightServiceAdapter.class
				.getName(), "callArrayExpressExperiments", "Keywords", "Accession", "Array", "Ef", "Efv", "Expdesign",
				"Exptype", "Gxa", "Pmid", "Sa", "Species", "Expandefo", "result");
	}

	
	
}
